package com.genia.toolbox.projects.sample_ws_trampo.war.ws.services.impl;

import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.cxf.interceptor.OutInterceptors;
import org.apache.log4j.Logger;

import com.genia.toolbox.projects.sample_ws_trampo.bean.model.impl.BookClassImpl;
import com.genia.toolbox.projects.sample_ws_trampo.war.ws.services.BookService;

/**
 * {@link BookService} implementation.
 */
@WebService (endpointInterface = "com.genia.toolbox.projects.sample_ws_trampo.war.ws.services.BookService")
/**
@InInterceptors(interceptors = "com.genia.toolbox.projects.sample_ws_trampo.war.ws.interceptor.CatchInInterceptor")
@OutInterceptors(interceptors = "com.genia.toolbox.projects.sample_ws_trampo.war.ws.interceptor.CatchOutInterceptor")
**/
@InInterceptors(interceptors = "com.genia.toolbox.security.annotation.ws_interceptor.CatchInInterceptor")
@OutInterceptors(interceptors = "com.genia.toolbox.security.annotation.ws_interceptor.CatchOutInterceptor")

public class BookServiceImpl implements BookService {

	private static final Log LOG = LogFactory.getLog(BookServiceImpl.class);
	private static final Logger logger = Logger.getLogger(BookServiceImpl.class);

	private BookClassImpl oneBook;

	private BookClassImpl twoBook;

	public BookServiceImpl() {
		oneBook = new BookClassImpl();
		oneBook.setAuthor("1Genia");
		oneBook.setTitle("CXF Tutorial");
		oneBook.setIsbn("1313131313");
		oneBook.setDescription("description CXF Tutorial");
		twoBook = new BookClassImpl();
		twoBook.setAuthor("AVS Consulting");
		twoBook.setTitle("CXF Advanced");
		twoBook.setIsbn("1413135316");
		twoBook.setDescription("description CXF advanced");
	}

	@WebMethod(operationName = "getBooks", action = "urn:getBooks")
	@WebResult(name = "myAnswer")
	public BookClassImpl[] getBooks(String msg) {
		InInterceptors inInterceptors = this.getClass().getAnnotation(InInterceptors.class);
		LOG.info("Context id = " + msg);
		logger.debug("Context id = "+msg);
		LOG.info(org.apache.cxf.interceptor.LoggingInInterceptor.class);
		LOG.info(inInterceptors);
		logger.debug(org.apache.cxf.interceptor.LoggingInInterceptor.class);
		logger.debug(inInterceptors);
		return new BookClassImpl[] { oneBook, twoBook };
	}

}
